<?php
require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path
require_once 'Zend/Gdata/YouTube.php'; // on charge la librairie YouTube

$yt = new Zend_Gdata_YouTube();

//pagination de $yt
$videoFeed = $yt->getUserUploads('lakombiprod');
function printEntireFeed($videoFeed, $counter) {
	
 foreach($videoFeed as $videoEntry) {
   echo $counter . " - " . $videoEntry->getVideoTitle() . "<br>";
   $counter++;
 }

 // See whether we have another set of results
 try {
   $videoFeed = $videoFeed->getNextFeed();
 } catch (Zend_Gdata_App_Exception $e) {
   echo $e->getMessage() . "<br>";
   return;
 }

 if ($videoFeed) {
   echo "-- next sets of results --<br>";
   printEntireFeed($videoFeed, $counter);
 }
}

//fonction recuperer et afficher la liste de videos
function getAndPrintVideoFeed()
{
	$yt = new Zend_Gdata_YouTube();
  // set the version to 2 to receive a version 2 feed of entries
  $yt->setMajorProtocolVersion(2);
  $videoEntry = $yt->getVideoEntry('the0KZLEacs');// c'est ici qu'on recupere la video UNIQUE
  printVideoEntry($videoEntry);// ici on entre la fonction qui affiche les infos de la video UNIQUE
}

function printVideoEntry($videoEntry) {
	
	// the videoEntry object contains many helper functions
  // that access the underlying mediaGroup object
  echo 'Video: ' . $videoEntry->getVideoTitle() . "<br>";
  echo 'Video ID: ' . $videoEntry->getVideoId() . "<br>";
  echo 'Updated: ' . $videoEntry->getUpdated() . "<br>";
  echo 'Description: ' . $videoEntry->getVideoDescription() . "<br>";
  echo 'Category: ' . $videoEntry->getVideoCategory() . "<br>";
  echo 'Tags: ' . implode(", ", $videoEntry->getVideoTags()) . "<br>";
  echo 'Watch page: ' . $videoEntry->getVideoWatchPageUrl() . "<br>";
  echo 'Flash Player Url: ' . $videoEntry->getFlashPlayerUrl() . "<br>";
  echo 'Duration: ' . $videoEntry->getVideoDuration() . "<br>";
  echo 'View count: ' . $videoEntry->getVideoViewCount() . "<br>";
  echo 'Rating: ' . $videoEntry->getVideoRatingInfo() . "<br>";
  echo 'Geo Location: ' . $videoEntry->getVideoGeoLocation() . "<br>";
  echo 'Recorded on: ' . $videoEntry->getVideoRecorded() . "<br>";
  
  // see the paragraph above this function for more information on the 
  // 'mediaGroup' object. in the following code, we use the mediaGroup
  // object directly to retrieve its 'Mobile RSTP link' child
  
  foreach ($videoEntry->mediaGroup->content as $content) {
    if ($content->type === "video/3gpp") {
      echo 'Mobile RTSP link: ' . $content->url . "<br>";
    }
  }
  
  echo "Thumbnails:<br>";
  $videoThumbnails = $videoEntry->getVideoThumbnails();

  foreach($videoThumbnails as $videoThumbnail) {
    echo $videoThumbnail['time'] . ' - ' . $videoThumbnail['url'];
    echo ' height=' . $videoThumbnail['height'];
    echo ' width=' . $videoThumbnail['width'] . "<br>";
  }
	?>
	<object width="425" height="350">
		<param name="movie" value="http://www.youtube.com/v/the0KZLEacs?version=3&f=videos&app=youtube_gdata"></param>
		<embed src="http://www.youtube.com/v/the0KZLEacs?version=3&f=videos&app=youtube_gdata" type="MEDIA_CONTENT_TYPE" width="425" height="350"></embed>
	</object>
	<?php
	
}

getAndPrintVideoFeed();

printEntireFeed($videoFeed, 1);
